package com.anyikang.volunteer.sos.volunteer.app.main;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

/**
 *
      广告栏Viewpager数据适配器
 */
class BannerPagerAdapter extends FragmentStatePagerAdapter {
	    int size = 0;
	    ArrayList<String> mBannerImgs;

		public BannerPagerAdapter(FragmentManager fm, ArrayList<String> bannerImgs) {
			super(fm);
			size = bannerImgs.size();
			mBannerImgs = bannerImgs;
		}

		@Override
		public Fragment getItem(int position) {
			String imgURL = null;
			if(size != 0)
			{
				imgURL = String.valueOf(mBannerImgs.get(position % size));
			}
			BannerItemFragmentDemo fragment = BannerItemFragmentDemo.newInstance(imgURL,position);

			return fragment;
		}

		@Override
		public int getItemPosition(Object object) {
			return POSITION_NONE;
		}

		@Override
		public int getCount() {
			return 10000;
		}



	public void setData( ArrayList<String> bannerImgs)
	{
		mBannerImgs = bannerImgs;
		size = mBannerImgs.size();
		notifyDataSetChanged();

	}
}